#ifndef _STRUCTURE_H_
#define _STRUCTURE_H_

#define Max_Connection 100
#define MAX_LENGTH 1000
#define MAX_FILE 100
#define MAX_NAME 32
#define IP_LENGTH 15

#include <pthread.h>


enum type_peer {SEED, LEECH, INTERESTED};

struct file {
  char name[MAX_NAME];
  enum type_peer type;
  unsigned int size;
  unsigned int piece_size;
  char key[MAX_NAME];
  long long buffer_map;
  struct client * clients;
};

struct database{
  struct file tab_file[MAX_FILE];
  int nb_file;
};

struct client {
  char IP[IP_LENGTH];
  int port;
  long long client_buffer_map;
  struct client * next;

  pthread_mutex_t mutex;
  short downloading;
};

typedef struct {
  char **argv;
  int portno;
  char *IP;
  char *buffer;
  void (*func)(char *); 
} args;

typedef struct {
  int portno;
  char *IP;
  char *buffer;
  void (*func)(char *,char *); 
} args_bis;


#endif 
